package com.derbysoft.defender.mp.api.requester;

import com.derbysoft.defender.mp.api.response.CallbackIp;

/**
 * <p>
 * 获取微信服务器IP地址<br/>
 * 如果公众号基于安全等考虑，需要获知微信服务器的IP地址列表，以便进行相关限制，可以通过该接口获得微信服务器IP地址列表或者IP网段信息。
 * </p>
 * Created by Afee Lee on 2017-03-19 16:08
 *
 * @author Afee Lee
 * @version 1.0
 * @see Object
 * @since 1.8
 */
public class CallbackIpRequester extends AbstractRequester {
    private static final String DEFAULT_URL = "https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token={access_token}";

    private String url = DEFAULT_URL;
    private String accessToken;

    public CallbackIpRequester(String accessToken) {
        this.accessToken = accessToken;
    }

    public String getUrl() {
        return url;
    }

    public CallbackIpRequester setUrl(String url) {
        this.url = url;
        return this;
    }

    public String getAccessToken() {
        return accessToken;
    }

    public CallbackIp request() {
        return getForEntity(url, CallbackIp.class, accessToken);
    }
}
